home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / amigae / gencodee_v22.lha / GenCodeE / sources / GenCodeE_v22 / GenCodeE.e < prev    next >
Encoding:
Text File  |  1994-11-22  |  3.2 KB  |  132 lines

  1. OPT OSVERSION=37
  2.  
  3.  
  4. ->*****
  5. ->** External modules
  6. ->*****
  7. MODULE 'muibuilder' , 'libraries/muibuilder'
  8. MODULE 'utility/tagitem'
  9.  
  10. MODULE '*MUIStrings'
  11. MODULE '*AuxProcs'
  12. MODULE '*Variable'
  13. MODULE '*GUIFile'
  14.  
  15.  
  16. ->*****
  17. ->** Exception handling
  18. ->*****
  19. RAISE    "LIB"    IF    OpenLibrary()    =    NIL    ,
  20.         "MBtf"    IF    Mb_Open()        =    NIL    ,
  21.         "MEM"    IF    String()        =    NIL
  22.  
  23.  
  24. /*******************
  25. ** Main procedure **
  26. *******************/
  27. PROC main() HANDLE
  28.  
  29.     DEF application = FALSE , declarations = FALSE , code = FALSE
  30.     DEF notifications = FALSE , environment = FALSE , locale = FALSE
  31.     DEF filename : PTR TO CHAR , catalog_filename : PTR TO CHAR
  32.     DEF catalog_name : PTR TO CHAR , getstring_func : PTR TO CHAR
  33.     DEF number_vars , vars : PTR TO variable , ident_length_max
  34.     DEF genfile = NIL : PTR TO gui_file
  35.     DEF tmp_string : PTR TO CHAR
  36.  
  37.     muibbase := OpenLibrary( 'muibuilder.library' , 0 )
  38.     Mb_Open()
  39.  
  40.     Mb_GetA( [    MUIB_VARNUMBER        , {number_vars}            ,
  41.                 MUIB_APPLICATION    , {application}            ,
  42.                 MUIB_DECLARATIONS    , {declarations}        ,
  43.                 MUIB_CODE            , {code}                ,
  44.                 MUIB_NOTIFICATIONS    , {notifications}        ,
  45.                 MUIB_ENVIRONMENT    , {environment}            ,
  46.                 MUIB_LOCALE            , {locale}                ,
  47.                 MUIB_FILENAME        , {filename}            ,
  48.                 MUIB_CATALOGNAME    , {catalog_filename}    ,
  49.                 MUIB_GETSTRINGNAME    , {getstring_func}        ,
  50.                 TAG_END ] )
  51.  
  52.     tmp_string := filename
  53.     filename := String( StrLen( filename ) + 3 )
  54.     StringF( filename , '\s.em' , tmp_string )
  55.  
  56.     catalog_filename := FilePart( catalog_filename )
  57.     catalog_name := String( StrLen( catalog_filename ) + 5 )
  58.     StringF( catalog_name , 'catalog_\s' , catalog_filename )
  59.  
  60.     vars , ident_length_max := init_variables( number_vars )
  61.  
  62.     NEW genfile.open( filename , number_vars , vars , ident_length_max )
  63.  
  64.     IF declarations
  65.  
  66.         IF environment THEN genfile.put_header( application , locale )
  67.         genfile.put_aux_objects( environment , application )
  68.         genfile.put_main_object( environment )
  69.         genfile.put_constants( environment )
  70.         genfile.put_global_vars( environment , locale , catalog_name )
  71.  
  72.     ENDIF
  73.  
  74.     IF code
  75.  
  76.         IF environment THEN genfile.put_create_declaration( application )
  77.         IF environment THEN genfile.put_create_local_defs()
  78.         IF environment THEN genfile.put_create_initialisations( locale , getstring_func )
  79.         genfile.put_code( getstring_func , muistrings_contents() )
  80.         IF environment THEN genfile.put_create_end()
  81.         IF environment THEN genfile.put_dispose_method()
  82.  
  83.     ENDIF
  84.  
  85.     IF notifications
  86.  
  87.         IF environment THEN genfile.put_init_notifications_declaration()
  88.         genfile.put_notifications( muistrings_contents() , getstring_func )
  89.         IF environment THEN genfile.put_init_notifications_end()
  90.  
  91.     ENDIF
  92.  
  93.     IF environment AND locale THEN genfile.put_aux_funcs()
  94.  
  95. EXCEPT DO
  96.  
  97.     SELECT exception
  98.  
  99.         CASE "MEM"
  100.  
  101.             error_request( 'Out of memory !' )
  102.  
  103.         CASE "LIB"
  104.  
  105.             error_request( 'Can''t open muibuilder.library !' )
  106.  
  107.         CASE "MBtf"
  108.  
  109.             error_request( 'Unable to get temporary files !' )
  110.  
  111.         CASE "OPEN"
  112.  
  113.             error_request( 'Unable to open file to generate !' )
  114.  
  115.         CASE "OUT"
  116.  
  117.             error_request( 'Trouble writing file to generate !' )
  118.  
  119.     ENDSELECT
  120.  
  121.     IF genfile    THEN genfile.close()
  122.     IF muibbase    THEN Mb_Close()
  123.     IF muibbase    THEN CloseLibrary( muibbase )
  124.  
  125. ENDPROC
  126.  
  127.  
  128. /*******************
  129. ** String version **
  130. *******************/
  131. CHAR '$VER: GenCodeE 2.2 (21.11.94)' , 0
  132.